<?php
require_once(__PHY_LIB.'/class/Item.class.php');

class uWorkSizeKuang extends Item {
/// definition and constructor ///
    function uWorkSizeKuang($id=0, $field="") {
        Query::Query();
        $this->cfgKeyField("id");
        $this->cfgAllField("id,work_id,size_id,title,title_en,price,price_en,description,description_en");
        $this->cfgTable("unit_work_size_kuang");
        if ("" == $field || "*" == $field) {
            $this->cfgField($this->mAllField);
        }
        else {
            $this->cfgField($field);
        }
        if (0 < $id) {
            $this->cfgWhere($this->mKeyField . "=" . $id);
            $this->load();
        }
        else {
            $this->set($this->mKeyField, $id);
        }
    }

    function invalid() {
        if (!$this->get('work_id')) {
            return 'work_id';
        }
        if (!$this->get('size_id')) {
            return 'size_id';
        }

        return false;
    }

} /// end class uWorkSizeKuang.


class uWorkSizeKuangList extends ItemList {
    /// definition and constructor ///
    function uWorkSizeKuangList($tablename=null) {
        ItemList::ItemList();
        $this->cfgClass("uWorkSizeKuang");
        $this->cfgKeyField("id");
        $this->cfgAllField("id,work_id,size_id,title,title_en,price,price_en,description,description_en");
        $this->cfgTable(null == $tablename ? "unit_work_size_kuang" : $tablename);
    }

} /// end class uWorkSizeKuangList.


/// related functions ///
function uWorkSizeKuang_i18n($nID, $sField) {
	static $rCache = array();
	if (!isset($rCache['LangFields'])) {
		$rCache['LangFields'] = '|title|description|price';
	}
	if (!isset($rCache[$nID])) {
		$oOne = new uWorkSizeKuang($nID);
		$rCache[$nID] = $oOne->getData();
	}
	if ('en' == $_SESSION['LANG'] && strpos($rCache['LangFields'], $sField)) {
		$sField .= '_en';
		return $rCache[$nID][$sField];
	}
	else { return $rCache[$nID][$sField]; }
}
?>
